<?php

namespace App\Http\Requests\AuthRequests;

use Illuminate\Foundation\Http\FormRequest;

class AnswerRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'problem_1_id' => ['required', 'exists:password_problems,id'],
            'answer_1'     => ['required', 'max:20'],
            'problem_2_id' => ['required', 'exists:password_problems,id'],
            'answer_2'     => ['required', 'max:20'],
            'problem_3_id' => ['required', 'exists:password_problems,id'],
            'answer_3'     => ['required', 'max:20'],
            'pay_password' => ['required', 'payPasswordFormat'],
        ];
    }


    public function messages()
    {
        return [
            'problem_1_id.required' => __('问题一ID必填'),
            'problem_1_id.exists'   => __('问题一ID不存在'),
            'answer_1.required'     => __('问题一答案必填'),
            'answer_1.max'          => __('问题一答案至多18位'),
            'problem_2_id.required' => __('问题二ID必填'),
            'problem_2_id.exists'   => __('问题二ID不存在'),
            'answer_2.required'     => __('问题二答案必填'),
            'answer_2.max'          => __('问题二答案至多18位'),
            'problem_3_id.required' => __('问题三ID必填'),
            'problem_3_id.exists'   => __('问题三ID不存在'),
            'answer_3.required'     => __('问题三答案必填'),
            'answer_3.max'          => __('问题三答案至多18位'),
            'pay_password.required' => __('交易密码必填'),
        ];
    }
}
